package wsi.gui.pref;

import java.awt.GridBagConstraints;
import java.awt.Insets;

import org.rygh.gui.swing.field.SStringField;
import org.rygh.gui.swing.view.SGridView;

import wsi.exp.ExpFolderController;
import wsi.script.AppConfig;

@SuppressWarnings("serial")
public class PrefFolderView extends SGridView {

	public PrefFolderView() {
		initComponents();
	}

	private void addField(SStringField field, int y) {
		Insets insets = new Insets(6, 10, 6, 10);
		GridBagConstraints c;

		field.setEditable(false);

		c = new GridBagConstraints();
		c.gridx = 0;
		c.gridy = y;
		c.weightx = 1.;
		c.insets = insets;
		c.fill = GridBagConstraints.HORIZONTAL;
		add(field.getLongView(), c);
	}

	private void initComponents() {
		int y = 0;

		AppConfig config = AppConfig.shared();
		ExpFolderController folder = ExpFolderController.shared();

		SStringField field = new SStringField("Functions");
		field.setText(config.getFunctionsFolder().getAbsolutePath());
		addField(field, y++);

		field = new SStringField("Experiments");
		field.setText(config.getExperimentsFolder().getAbsolutePath());
		addField(field, y++);

		field = new SStringField("Exp 1");
		field.setText(folder.getFolderForExp1().getAbsolutePath());
		addField(field, y++);

		field = new SStringField("Exp 1 Gold");
		field.setText(folder.getGoldFolderForExp1().getAbsolutePath());
		addField(field, y++);

		field = new SStringField("Exp 2");
		field.setText(folder.getFolderForExp2().getAbsolutePath());
		addField(field, y++);

		field = new SStringField("Exp 2 Gold");
		field.setText(folder.getGoldFolderForExp2().getAbsolutePath());
		addField(field, y++);

		field = new SStringField("Exp 3");
		field.setText(folder.getFolderForExp3().getAbsolutePath());
		addField(field, y++);

		field = new SStringField("Exp 3 Gold");
		field.setText(folder.getGoldFolderForExp3().getAbsolutePath());
		addField(field, y++);

		field = new SStringField("Exp 4");
		field.setText(folder.getFolderForExp4().getAbsolutePath());
		addField(field, y++);

	}
}
